-#-----------------------------------------------------------------
  WARNING: Please keep changes up-to-date with the following files:
  - `assets/javascripts/diffs/components/commit_item.vue`

  EXCEPTION WARNING - see above `.vue` file for de-sync drift

  WARNING: When introducing new content here, please consider what
           changes may need to be made in the cache keys used to
           wrap this view, found in
           CommitsHelper#commit_partial_cache_key
-#-----------------------------------------------------------------
- view_details      = local_assigns.fetch(:view_details, false)
- merge_request     = local_assigns.fetch(:merge_request, nil)
- project           = local_assigns.fetch(:project) { merge_request&.project }
- ref               = local_assigns.fetch(:ref) { merge_request&.source_branch }
- commit            = commit.present(current_user: current_user)
- commit_status     = commit.detailed_status_for(ref)
- tags              = commit.tags_for_display
- collapsible       = local_assigns.fetch(:collapsible, true)
- link_data_attrs   = local_assigns.fetch(:link_data_attrs, {})
- link              = commit_path(project, commit, merge_request: merge_request)
- show_project_name = local_assigns.fetch(:show_project_name, false)

%li{ class: ["commit flex-row", ("js-toggle-container" if collapsible)], id: "commit-#{commit.short_id}" }
  .avatar-cell.d-none.d-sm-block
    = author_avatar(commit, size: 40, has_tooltip: false)

  .commit-detail.flex-list.gl-display-flex.gl-justify-content-space-between.gl-align-items-center.gl-flex-grow-1.gl-min-w-0
    .commit-content{ data: { qa_selector: 'commit_content' } }
      - if view_details && merge_request
        = link_to commit.title, project_commit_path(project, commit.id, merge_request_iid: merge_request.iid), class: ["commit-row-message item-title js-onboarding-commit-item", ("font-italic" if commit.message.empty?)]
      - else
        = link_to_markdown_field(commit, :title, link, class: "commit-row-message item-title js-onboarding-commit-item #{'font-italic' if commit.message.empty?}", data: link_data_attrs)
      %span.commit-row-message.d-inline.d-sm-none
        &middot;
        = commit.short_id
      - if commit.description? && collapsible
        = render Pajamas::ButtonComponent.new(icon: 'ellipsis_h',
          button_options: { class: 'button-ellipsis-horizontal text-expander js-toggle-button', data: { toggle: 'tooltip', container: 'body' }, :title => _("Toggle commit description"), aria: { label: _("Toggle commit description") }})

      .committer
        - commit_author_link = commit_author_link(commit, avatar: false, size: 24)
        - commit_authored_timeago = time_ago_with_tooltip(commit.authored_date, placement: 'bottom')
        - if commit.different_committer? && commit.committer
          - commit_committer_link = commit_committer_link(commit)
          - commit_committer_timeago = time_ago_with_tooltip(commit.committed_date, placement: 'bottom')
          - commit_committer_avatar = commit_committer_avatar(commit.committer, size: 18, has_tooltip: false)
          - commit_text =  _('%{commit_author_link} authored %{commit_authored_timeago} and %{commit_committer_avatar} %{commit_committer_link} committed %{commit_committer_timeago}') % { commit_author_link: commit_author_link, commit_authored_timeago: commit_authored_timeago, commit_committer_avatar: commit_committer_avatar, commit_committer_link: commit_committer_link, commit_committer_timeago: commit_committer_timeago }
        - else
          - commit_text =  _('%{commit_author_link} authored %{commit_authored_timeago}') % { commit_author_link: commit_author_link, commit_authored_timeago: commit_authored_timeago }
        #{ commit_text.html_safe }
      = render_if_exists 'projects/commits/project_namespace', show_project_name: show_project_name, project: project

      - if commit.description?
        %pre{ class: ["commit-row-description gl-mb-3 gl-white-space-pre-line", (collapsible ? "js-toggle-content" : "d-block")] }
          = preserve(markdown_field(commit, :description))

    .commit-actions.flex-row
      - if tags.present?
        = gl_badge_tag(variant: :neutral, icon: 'tag', class: 'gl-font-monospace') do
          - if tags.size > 1
            = link_to _('%{count} tags') % { count: tags.size } , project_commit_path(project, commit.id)
          - else
            = link_to tags.first, project_commits_path(project, tags.first, ref_type: 'tags'), class: 'gl-text-truncate gl-max-w-15'

      - if request.xhr?
        = render partial: 'projects/commit/signature', object: commit.signature
      - else
        = render partial: 'projects/commit/ajax_signature', locals: { commit: commit }

      - if commit_status
        = render_commit_status(commit, commit_status, ref: ref)

      .js-commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id, ref: ref) } }

      .commit-sha-group.btn-group.d-none.d-sm-flex
        .label.label-monospace.monospace
          = commit.short_id
        = clipboard_button(text: commit.id, title: _("Copy commit SHA"), class: "gl-button btn btn-default btn-icon", container: "body")
        = link_to_browse_code(project, commit)
